package com.woniuxy.dr_mall.provider;

import com.woniuxy.dr_mall.entity.DrUser;
import org.apache.ibatis.jdbc.SQL;

public class DrUserProvider {
    public String update(DrUser user){
        return new SQL(){
            {
                UPDATE("dr_user");
                if(user.getAccount()!=null && user.getAccount().length()!=0){
                    SET("account='"+user.getAccount()+"'");
                }
                if(user.getPassword()!=null && user.getPassword().length()!=0){
                    SET("password='"+user.getPassword()+"'");
                }
                if(user.getName()!=null && user.getName().length()!=0){
                    SET("name='"+user.getName()+"'");
                }
                if(user.getTel()!=null && user.getTel().length()!=0){
                    SET("tel='"+user.getTel()+"'");
                }
                if(user.getNickname()!=null && user.getNickname().length()!=0){
                    SET("nickName='"+user.getNickname()+"'");
                }
                if(user.getGender()!=null && user.getGender().length()!=0){
                    SET("gender='"+user.getGender()+"'");
                }
                if(user.getBirthday()!=null && user.getBirthday().length()!=0){
                    SET("birthday='"+user.getBirthday()+"'");
                }
                if(user.getProvince() !=null &&user.getProvince().length()!=0){
                    SET("province='"+user.getProvince()+"'");
                }
                if(user.getCity() !=null &&user.getCity().length()!=0){
                    SET("city='"+user.getCity()+"'");
                }
                if(user.getDistrict()!=null &&user.getDistrict().length()!=0){
                    SET("district='"+user.getDistrict()+"'");
                }
                if(user.getAddress()!=null && user.getAddress().length()!=0){
                    SET("address='"+user.getAddress()+"'");
                }
                if(user.getAvatar()!=null && user.getAvatar().length()!=0){
                    SET("avatar='"+user.getAvatar()+"'");
                }
                if(user.getIdCard()!=null && user.getIdCard().length()!=0){
                    SET("IdCard='"+user.getIdCard()+"'");
                }
                WHERE("id="+user.getId());
            }
        }.toString();
    }
}
